﻿using System;
using Google.Analytics.Model.Feeds;
using NUnit.Framework;

namespace Google.Analytics.ModelTests
{
    public class DataFeedTests : ModelTestBase
    {
        [Test]
        public void Constructor()
        {
            var uri = new Uri("http://www.test.com");
            var feed = new DataFeed(uri, Service);

            var result = feed.GetAbsoluteUri("");
            Assert.AreEqual(uri.AbsoluteUri, result, "Invalid url");
        }

        [Test]
        public void NullUrl()
        {
            var feed = new DataFeed(null, Service);

            var result = feed.GetAbsoluteUri("");
            Assert.AreEqual("Unsupported URI format", result, "Null uri allowed");
        }

        [Test]
        public void TestService()
        {
            var uri = new Uri("http://www.test.com");
            var feed = new DataFeed(uri, null);

            Assert.IsNull(feed.Service, "Service is not null");
        }

        [Test]
        public void CheckCredentials()
        {
            var uri = new Uri("http://www.test.com");
            var feed = new DataFeed(uri, Service);

            var result = feed.Service.Credentials;
            Assert.AreEqual(result.Username, "username", "Invalid username");
        }
    }
}
